﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;

namespace StandardManager
{
    public class GlobalConfig
    {
        private static GlobalConfig m_instance=null;
        public static GlobalConfig Instance { get { if (m_instance == null) { m_instance = new GlobalConfig(); m_instance.Load(); } return m_instance; } }
        public string DBFileName { get; set; } = @"D:\b\徐州-CIM\18.标准\标准库\standard.db";
        public string EntityDBFileName { get; set; } = @"D:\git9\StandardManager\StandardManager\TestData\standardEntity.db";
        public string UmiOCR { get; set; } = @"D:\Umi-OCR_Rapid_v2.1.4\Umi-OCR.exe";

        public void Load()
        {
            if (File.Exists("GlobalConfig.txt")==false)
            {
                return;
            }
            var ts = File.ReadAllLines("GlobalConfig.txt");
            DBFileName = ts[0];
            UmiOCR = ts[1];
            EntityDBFileName = ts.Length >= 3 ? ts[2] : EntityDBFileName;
        }

        public void Save()
        {
            File.WriteAllLines("GlobalConfig.txt", new string[] { DBFileName, UmiOCR, EntityDBFileName });
        }
    }
}
